package com.atguigu.tingshu.model.search;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.CompletionField;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.core.suggest.Completion;

@Data
@Document(indexName = "suggestinfo")
@JsonIgnoreProperties(ignoreUnknown = true)//目的：防止json字符串转成实体对象时因未识别字段报错
public class SuggestIndex {

    /**
     * 文档ID 跟专辑文档ID一致
     * 目的：同步新增 同步删除
     */
    @Id
    private String id;

    /**
     * 原始内容：用于解析建议词结果后给用户查看
     * 比如：经典留声机
     */
    @Field(type = FieldType.Text, analyzer = "standard")
    private String title;

    /**
     * 中文自动补全字段
     * 比如：经 典 留 声 机
     */
    @CompletionField(analyzer = "standard", searchAnalyzer = "standard", maxInputLength = 20)
    private Completion keyword;

    /**
     * 中文对应汉语拼音自动补全字段
     * 比如：jingdianliushengji
     */
    @CompletionField(analyzer = "standard", searchAnalyzer = "standard", maxInputLength = 20)
    private Completion keywordPinyin;

    /**
     * 中文对应汉语拼音首字母自动补全字段
     * 比如：jdlsj
     */
    @CompletionField(analyzer = "standard", searchAnalyzer = "standard", maxInputLength = 20)
    private Completion keywordSequence;

}
